//
//  MainViewController.swift
//  许鲜
//
//  Created by hbl on 16/4/22.
//  Copyright © 2016年 hbl. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        setupChilds()
        
    }
    
    private func setupChilds(){
        
        let home = HomeViewController()
        setupChild(home, title: "首页", imageName: "60Main")
        
        let shopping = ShoppingViewController()
        setupChild(shopping, title: "购物车", imageName: "60Cart")
        
        let near = NearTableViewController()
        setupChild(near, title: "附近", imageName: "60BBS")
        
        let me = MeViewController()
        setupChild(me, title: "我", imageName: "60Person")
    }

        private func setupChild(vc:UIViewController, title:String, imageName:String){
        
            if !(title == "我") {
                let nav = BLNavigationViewController(rootViewController: vc)
                nav.title = title
                nav.tabBarItem.image = UIImage(named:imageName)
                addChildViewController(nav)
            }else{
                vc.tabBarItem.image = UIImage(named:imageName)
                vc.title = title
                addChildViewController(vc)
            }
        
    }

}
